<?php

namespace app\admin\controller;

use think\Controller;

class Comment extends Controller
{
    //评论列表
    public function all()
    {
//        model('Comment')->save([
//            'content' => '垃圾文章',
//            'article_id' => 1,
//            'member_id' => 6
//        ]);
        $comments = model('Comment')->with('members,articles')->order('create_time', 'desc')->paginate(10);
        $this->assign('comments', $comments);
        return view();
    }

    //评论删除
    public function del(){
        $comments = model('Comment')->find(input('post.id'));
        $result =  $comments->delete();
        if ($result){
            $this->success('删除成功', 'admin/comment/all');
        }else{
            $this->error('删除失败');
        }
    }
}
